﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.model
{
    public class L1ShopSellOrder
    {
        private L1AssessedItem _item;
        private int _count;

        public L1ShopSellOrder( L1AssessedItem item, int count )
        {
            _item = item;
            _count = count;
        }

        public L1AssessedItem getItem()
        {
            return _item;
        }

        public int getCount()
        {
            return _count;
        }

    }

    public class L1ShopSellOrderList
    {
        private L1Shop _shop;
        private L1PcInstance _pc;
        private List<L1ShopSellOrder> _list = new List<L1ShopSellOrder>();

        public L1ShopSellOrderList( L1Shop shop, L1PcInstance pc )
        {
            _shop = shop;
            _pc = pc;
        }

        public void add( int itemObjectId, int count )
        {
            L1AssessedItem assessedItem = _shop.assessItem( _pc.getInventory()
                    .getItem( itemObjectId ) );
            if ( assessedItem == null )
            {
                /*
                 * 買取リストに無いアイテムが指定された。 不正パケの可能性。
                 */
                throw new ArgumentException();
            }

            _list.Add( new L1ShopSellOrder( assessedItem, count ) );
        }

        public L1PcInstance getPc()
        {
            return _pc;
        }

        public List<L1ShopSellOrder> getList()
        {
            return _list;
        }
    }
}
